angular.module('vote').controller('voteListCtrl', ['$scope', '$http', '$timeout', '$uibModal', function ($scope, $http, $timeout, $uibModal) {
    $scope.dataList = [];
    $scope.onInit = function () {
        $http.post(ctx + '/vote/list').then(function (resp) {
            $scope.dataList = resp.data;
        });
    }
    $scope.onInit();
    //添加或修改
    $scope.editVote = function (id) {
        var modalInstance = $uibModal.open({
            backdrop: 'static',
            templateUrl: 'app/modules/vote/vote.detail.html',
            controller: 'voteDetailCtrl',
            resolve: {
                id: function () {
                    return id;
                }
            }
        });
        modalInstance.result.then(function () {
            $scope.successFlag = true;
            $scope.onInit();
            $timeout(function () {
                $scope.successFlag = false;
            }, 1000);
        }, function () {
        });
    };
    $scope.see = function (id) {
        var modalInstance = $uibModal.open({
            // backdrop: 'static',
            templateUrl: 'app/modules/vote/vote.see.html',
            controller: 'voteSeeCtrl',
            resolve: {
                id: function () {
                    return id;
                }
            }
        });
        modalInstance.result.then(function () {
        }, function () {
        });
    }
    $scope.qrCode = function (id) {
        var modalInstance = $uibModal.open({
            // backdrop: 'static',
            templateUrl: 'app/modules/vote/qrcode.html',
            controller: 'qrcodeCtrl',
            resolve: {
                id: function () {
                    return id;
                }
            }
        });
        modalInstance.result.then(function () {
        }, function () {
        });
    }
    $scope.managePrize = function (id) {
        var modalInstance = $uibModal.open({
            // backdrop: 'static',
            templateUrl: 'app/modules/vote/managePrize.html',
            controller: 'managePrizeCtrl',
            resolve: {
                id: function () {
                    return id;
                }
            }
        });
        modalInstance.result.then(function () {
            $scope.onInit();
            $scope.successFlag = true;
            $scope.onInit();
            $timeout(function () {
                $scope.successFlag = false;
            }, 1000);
        }, function () {
        });
    }
}]);